import pydantic
import enum


class ResultItem(pydantic.BaseModel):
    msg: str
    code: int

    def __str__(self):
        return f"({self.code}, {self.msg})"


class Result(enum.Enum):
    # 节点
    PROXIED = ResultItem(msg="任务已被代理", code=0)
    # 依赖
    UNAVAILABLE_TASK = ResultItem(msg="任务不满足条件", code=1)
    UNAVAILABLE_STEP = ResultItem(msg="步骤不满足条件", code=2)
    UNAVAILABLE_MODULE = ResultItem(msg="模块不满足条件", code=3)
    # 执行
    EXECUTOR_NOT_FOUND = ResultItem(msg="执行器未找到", code=4)
    EXECUTOR_INTERRUPT = ResultItem(msg="执行器中断", code=5)
    EXECUTOR_CMD_ERROR = ResultItem(msg="执行器命令错误", code=6)
    EXECUTOR_TIMEOUT = ResultItem(msg="执行器超时", code=7)
    EXECUTOR_UNKNOWN = ResultItem(msg="执行器未知错误", code=8)
    TASK_INTERRUPT = ResultItem(msg="任务中断", code=14)
    # 框架
    REBOOT_FAIL = ResultItem(msg="重启失败", code=9)
    FRAMEWORK_ERROR = ResultItem(msg="内部错误", code=10)
    NOT_IMPL = ResultItem(msg="未实现", code=11)
    # 结果
    FAIL = ResultItem(msg="预期结果未达到", code=12)
    SUCCESS = ResultItem(msg="预期结果已达到", code=13)
